home *** CD-ROM | disk | FTP | other *** search
- Path: cypher.3do.com!user
- From: tsw@3do.com (Tom Watson)
- Newsgroups: comp.lang.c
- Subject: Re: Where Can I Find Standard C Library Sourc
- Date: Thu, 08 Feb 1996 11:26:44 -0800
- Organization: The 3DO Corporation
- Distribution: world
- Message-ID: <tsw-0802961126440001@cypher.3do.com>
- References: <4f8915$jt@mother.usf.edu> <4fb8mf$ouo@spanky.pls.ov.com>
- NNTP-Posting-Host: cypher.3do.com
-
- In article <4fb8mf$ouo@spanky.pls.ov.com>, glenn@ov.com wrote:
-
- > In article jt@mother.usf.edu, yatesc@csee.usf.edu (Randy Yates) writes:
- > >I mean the source for functions like printf and strcpy.
- > >
- > >I've read the FAQ but didn't see anything about this.
- <<<<<Deletia>>>
- >
- > printf is usually very system specific once you get down to the level
- > of actually outputting characters to a display device. Therefore,
- > you can only talk about source for a specific platform.
- >
- > As for strcpy:
- >
- > int strcpy(char *destination, char *source)
- > {
- > while((*destination++ = *source++) != '\0');
- > }
- >
-
- One should read something about the return value for 'strcpy'. A more
- 'correct' version of this is something like:
-
- char *strcpy (char *destination, const char *source)
- {
- char *ret = destination;
- while ((*destination++ = *source++) != '\0')
- ;
- return ret;
- }
-
- The other forms of the while statement (or other looping structure used in
- its place) are left as an excercise of the reader. There are several
- forms that it can take, and most of them will have the desired result. If
- the compiler is good, they all will be efficient. Inclusion of "Duff's
- device" is also left as an excercise for the reader.
-
- > In general, it depends on the purpose of the function as to how
- > platform independent the source is. Usually anything that uses
- > system hardware (I/O devices, Floating Point Units, etc) is
- > system dependent, and just about everything else is not.
- >
- > Fletcher.Glenn@ov.com
-
- A "really good source" of library routines for C is Plauger's book (_The
- Standard C Library_) which is VERY good at explaining the library, AND how
- to use it. The portion of the standard relating to the library routines
- is also included, and is VERY helpful in the explainations as well. All
- in all a VERY recommended book.
-
- P.S. It has the source as well, and is pretty much system independent.
-
- --
- Tom Watson
- tsw@3do.com (Home: tsw@johana.com)
-